# Copyright 2015 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if {![istarget "powerpc*"] || ![is_lp64_target]} {
    verbose "Skipping powerpc64 separate debug file symtab test."
    return
}

standard_testfile

set kobz2file ${srcdir}/${subdir}/cordic.ko.bz2
set kofile ${objdir}/${subdir}/cordic.ko
set kodebugbz2file ${srcdir}/${subdir}/cordic.ko.debug.bz2
set kodebugfile ${objdir}/${subdir}/cordic.ko.debug

if {[catch "system \"bzip2 -dc ${kobz2file} >${kofile}\""] != 0} {
    untested "failed bzip2 for ${kobz2file}"
    return -1
}
if {[catch "system \"bzip2 -dc ${kodebugbz2file} >${kodebugfile}\""] != 0} {
    untested "failed bzip2 for ${kodebugbz2file}"
    return -1
}

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir

# This test won't work properly if system debuginfo is installed.
# Test message is suppressed by "" as otherwise we could print PASS+UNTESTED
# result to gdb.sum making a false feeling the issue has been tested.
gdb_test_no_output "set debug-file-directory" ""

gdb_load ${kofile}

set test "show architecture"
gdb_test_multiple $test $test {
    -re "\r\nThe target architecture is set automatically \\(currently powerpc:common64\\)\r\n$gdb_prompt $" {
	pass $test
    }
    -re "\r\nThe target architecture is set automatically \\(currently .*\\)\r\n$gdb_prompt $" {
	untested "powerpc:common64 is not supported"
    }
}
